package com.coocaa.typhoon.api.config;

import com.coocaa.cirrus.common.base.model.RespBase;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author bijiahao
 * @date : 2025/9/18 16:25
 * @description
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionConfig {
    @ExceptionHandler({Exception.class})
    @ResponseBody
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public Object exceptionHandler(Exception exception) {
        log.error(exception.getMessage(), exception);
        return new RespBase().setFailResult(exception.getMessage());
    }
}
